package zencstudio.sgrealtor.adapter;

import java.util.List;

import zencstudio.sgrealtor.model.PropertyLocation;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import zencstudio.sgrealtor.R;

public class PropertyLocationSpinnerAdapter extends ArrayAdapter<PropertyLocation>{

	private Context context;
	private List<PropertyLocation>pLocation;
	public PropertyLocationSpinnerAdapter(Context context, int textViewResourceId,
			List<PropertyLocation> objects) {
		super(context, textViewResourceId, objects);
		this.context = context;
		this.pLocation = objects;
	}

	public int getCount() {
		return pLocation.size();
	}

	public PropertyLocation getItem(int position) {
		return pLocation.get(position);
	}

	public long getItemId(int position) {
		return position;
	}
	// And the "magic" goes here
    // This is for the "passive" state of the spinner
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // I created a dynamic TextView here, but you can reference your own  custom layout for each spinner item
        TextView label = new TextView(context);
        label.setTextColor(context.getResources().getColor(R.color.OrangeRed));
        // Then you can get the current item using the values array (Users array) and the current position
        // You can NOW reference each method you has created in your bean object (User class)
        label.setText(pLocation.get(position).getName());

        // And finally return your dynamic (or custom) view for each spinner item
        return label;
    }

   /* // And here is when the "chooser" is popped up
    // Normally is the same view, but you can customize it if you want
    @Override
    public View getDropDownView(int position, View convertView,
            ViewGroup parent) {
        TextView label = new TextView(context);
        label.setTextColor(Color.BLACK);
        label.setText(pLocation.get(position).getName());

        return label;
    }
*/
}
